#include <iostream>
#include <vector>
#include <random>
#include <map>
#include <algorithm> 

using namespace std;


int Binary_search(std::vector<int> &v, const int value)
{
    int left = 0;
    int right = v.size() -1;

    while(left <= right)
    {
        int mid = left + (right - left) / 2;//防止数据上溢出
        if(v.at(mid) == value)
            return mid;
        if(value < v.at(mid))
            right = mid - 1;
        if(value > v.at(mid))
            left = mid + 1;
    }
    return -1;
}








int main()
{
    vector<int> v= {1, 2, 3, 4, 5, 6};
    vector<int> v2 = {1, 3};
    // swap_ranges(v1,);
    //移除性算法
    vector<int> df;

    //插入排序
    // sort(v.begin(), v.end());
    // for_each(v.begin(), v.end(), [](int num){cout<<num<<" "});

    cout<<*lower_bound(v.begin(), v.end(), 3)<<endl;

    map<int, string> student;
    student.insert({1, "张三"});
    student.insert(std::make_pair(12, "李四"));
    //ite 迭代器
    for(auto ite = student.begin(); ite != student.end(); ite++)
    {   
        std::cout << "Key: " << ite->first << ", Value: " << ite->second << std::endl;
    }

    auto pair = equal_range(v.begin(), v.end(), 2);
    vector<int> v3(10);

    string str = "hello";
    string str2 = "world";
    cout<<accumulate(str.begin(), str.end(), str2)<<endl;

}
